package dijkstraAlg;

import java.util.LinkedList;

public class Map {
    LinkedList<Node> nodes;
    LinkedList<Path> paths;
    Node origin;
    public Map() {
        nodes = new LinkedList<>();
        paths = new LinkedList<>();
    }
    public void addNode(Character c){
        nodes.add(new Node(c));
    }
    public void addNode(Node n) {
        nodes.add(n);
    }
    public void addPath(Path p) {
        if (paths.contains(p))
            throw new RuntimeException("Path already exists");
        if (!nodes.contains(p.start))
            throw new RuntimeException("Node does not exist");
        if (!nodes.contains(p.end))
            throw new RuntimeException("Node does not exist");
        paths.add(p);
    }
    public void addPath(Node start, Node end,int distance) {
        addPath(new Path(start, end, distance));
    }

    public Node getOrigin() {
        return origin;
    }

    public void setOrigin(Node origin) {
        this.origin = origin;
    }
}